package com.pinc.cpbl;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class RankItem_Adapter extends BaseAdapter {

	private LayoutInflater inflater;
	private List<RankPacker> items;

	public RankItem_Adapter(Context context) {
		super();
		inflater = LayoutInflater.from(context);
		items = new ArrayList<RankPacker>();
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = inflater.inflate(R.layout.rank_item, null);

		TextView tv1 = (TextView)view.findViewById(R.id.textView1);
		TextView tv2 = (TextView)view.findViewById(R.id.textView2);
		TextView tv3 = (TextView)view.findViewById(R.id.textView3);
		TextView tv4 = (TextView)view.findViewById(R.id.textView4);
		TextView tv5 = (TextView)view.findViewById(R.id.textView5);
		TextView tv6 = (TextView)view.findViewById(R.id.textView6);

		tv1.setText(items.get(position).strArr[0].trim());
		tv2.setText(items.get(position).strArr[1]);
		tv3.setText(items.get(position).strArr[2]);
		tv4.setText(items.get(position).strArr[3]);
		tv5.setText(items.get(position).strArr[4]);
		tv6.setText(items.get(position).strArr[5]);

		return view;
	}

	public void add(List<String> strlist)
	{
		RankPacker rank = new RankPacker(strlist);
		items.add(rank);
	}

	private class RankPacker{
		public String[] strArr;

		public RankPacker(List<String> strlist)
		{
			strArr = new String[6];
			for(int i=0;i<6;i++)
				strArr[i] = strlist.get(i);
		}
	}
}
